package manage.util;

import manage.model.Attendance;
import manage.model.Attendancesub;


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

public class DateUtil {

    public static Attendancesub setSub(Attendancesub attendancesub,Attendance attendance){

        if(attendance.getTitle1().equals("正常")){
            attendancesub.setZc(attendancesub.getZc()+1);
        }
        if(attendance.getTitle1().equals("迟到")){
            attendancesub.setCd(attendancesub.getCd()+1);
        }
        if(attendance.getTitle1().equals("早退")){
            attendancesub.setZt(attendancesub.getZt()+1);
        }
        if(attendance.getTitle1().equals("旷工")){
            attendancesub.setKg(attendancesub.getKg()+1);
        }
        if(attendance.getTitle1().equals("请假")){
            attendancesub.setQj(attendancesub.getQj()+1);
        }
        if(attendance.getTitle1().equals("出差")){
            attendancesub.setCc(attendancesub.getCc()+1);
        }

        if(attendance.getTitle2().equals("正常")){
            attendancesub.setZc(attendancesub.getZc()+1);
        }
        if(attendance.getTitle2().equals("迟到")){
            attendancesub.setCd(attendancesub.getCd()+1);
        }
        if(attendance.getTitle2().equals("早退")){
            attendancesub.setZt(attendancesub.getZt()+1);
        }
        if(attendance.getTitle2().equals("旷工")){
            attendancesub.setKg(attendancesub.getKg()+1);
        }
        if(attendance.getTitle2().equals("请假")){
            attendancesub.setQj(attendancesub.getQj()+1);
        }
        if(attendance.getTitle2().equals("出差")){
            attendancesub.setCc(attendancesub.getCc()+1);
        }
        return attendancesub;
    }

    public static String getDate(Date date){
        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM");
        String da =sdf1.format(date);
        return da;
    }

}
